/*jslint vars: true, forin: true, sloppy: true */
/*global angular, probe, URLs*/

probe.run(function ($httpBackend) {
	//let oc-dialog pass through
	$httpBackend.whenGET(/\.html$/).passThrough();
	$httpBackend.whenGET(URLs.APIOriginUrl + "probe/origin").respond({
		"data": {
			"origin": "http://localhost:8080/index.html"
		}
	});
	$httpBackend.whenGET(URLs.APIOriginUrl + "probe/project").respond({});
	//更新探针会话状态
	$httpBackend.whenGET(URLs.APIOriginUrl + "probe/noop").respond({});
	//查询会话状态
	$httpBackend.whenGET(URLs.APIOriginUrl + "probe/session").respond({
		data: {
			"user": { //用户部分信息
				"name": "1010101010" //用户名
			},
			"limitation": { //限额情况
				"caseNumber": 5, //case限额
				"dictionaryNumber": 5, //字典限额
				"objectNumber": 15, //元件限额
				"processNumber": 5 //子过程限额
			},
			"project": { //项目概况
				"projectId": 1,
				"name": "lemonprobe",
				"comment": "mock data"
			},
			"probe": { //探针情况
				"config": {
					"origin": "./",
					"defaultMode": 0
				}
			}
		}
	});
	//激活探针
	$httpBackend.whenPOST(URLs.APIOriginUrl + "probe/login").respond({
		data: {
			probeCode: 'SHA-1_String',
			token: 'aaaa-1111'
		}
	});
	//创建一个仿真测试用例
	$httpBackend.whenPOST(URLs.APIOriginUrl + "case/").respond({});
	//修改一个仿真测试用例
	$httpBackend.whenPUT(new RegExp("^" + URLs.APIOriginUrl + "case/" + "\\d+$")).respond({});
	//删除一个仿真测试用例
	$httpBackend.whenDELETE(new RegExp("^" + URLs.APIOriginUrl + "case/" + "\\d+$")).respond({});
	//查询一个仿真测试用例
	$httpBackend.whenGET(new RegExp("^" + URLs.APIOriginUrl + "case/" + "\\d+$")).respond({
		data: {
			"case": {
				"caseId": 2, //用例的ID
				"name": 'sao', //用例的名称
				"code": "//simple case\n" +
"#set MAX_LOOP 12;\n" +
"#set NEXT_LOOP_DELAY 3333;\n" +
"\n" +
"	process main {\n" +
"		click \"button.danger\";\n" +
"		click \"img.ng-scope\";\n" +
"	}", //用例程序代码
				"comment": '', //测试用例描述
				"createtime": 43523534534, //创建时间
				"updatetime": 43523534534 //最近修改时间
			}
		}
	});
	//查询仿真测试用例列表
	$httpBackend.whenGET(URLs.APIOriginUrl + "case/list").respond({
		data: {
			"cases": [
				{
					"caseId": 0, //用例的ID
					"name": 'qwer', //用例的名称
					"updatetime": 11876543210 //最近修改时间
				},{
					"caseId": 1,
					"name": 'asdf',
					"updatetime": 12876543210
				},{
					"caseId": 2,
					"name": 'zxcv',
					"updatetime": 13876543210
				}
			]
		}
	});
	//查询公共元件列表
	$httpBackend.whenGET(URLs.APIOriginUrl + "object/").respond({
		data: {
			"objects": angular.toJson([
				{
					"objectId": 1234, //用例的ID
					"name": '元件1', //用例的名称
					"cssPath": '#new', //css选择器路径
					"createtime": 211876543210, //创建时间
					"updatetime": 212876543210 //最近修改时间
				}, {
					"objectId": 1235,
					"name": '元件2',
					"cssPath": '.like',
					"createtime": 221876543210,
					"updatetime": 232876543210
				}, {
					"objectId": 1236,
					"name": '元件3',
					"cssPath": 'body > nav',
					"createtime": 241876543210,
					"updatetime": 252876543210
				}
			])
		}
	});
	//修改元件库
	$httpBackend.whenPUT(URLs.APIOriginUrl + "object/").respond({});
	//创建一个数据字典
	$httpBackend.whenPOST(URLs.APIOriginUrl + "dictionary/").respond({});
	//修改一个数据字典
	$httpBackend.whenPUT(new RegExp("^" + URLs.APIOriginUrl + "dictionary/" + "\\d+$")).respond({});
	//删除一个数据字典
	$httpBackend.whenDELETE(new RegExp("^" + URLs.APIOriginUrl + "dictionary/" + "\\d+$")).respond({});
	//查询一个数据字典
	$httpBackend.whenGET(new RegExp("^" + URLs.APIOriginUrl + "dictionary/" + "\\d+$")).respond({
		data: {
			"dictionary": {
				"dictionaryId": 222,
				"name": 'mock字典',
				"comment": '毫无存在感',
				"field": '[{"name":"阿萨德","pattern":"[asdf]{1,2}","comment":""},{"name":"confusing","pattern":"[/]{3,5}","comment":"sfdadsgfglk"}]',
				"assignment": '[["4324","4312"],["dffsgfg","65y6y"],[]]',
				"createtime": 211876543210, //创建时间
				"updatetime": 212876543210 //最近修改时间
			}
		}
	});
	//查询数据字典列表
	$httpBackend.whenGET(URLs.APIOriginUrl + "dictionary/list").respond({
		data: {
			"dictionaries": [
				{
					"dictionaryId": 222,
					"name": '孙子兵法',
					"updatetime": 212876543210 //最近修改时间
				}, {
					"dictionaryId": 223,
					"name": '吴子',
					"updatetime": 312876543210 //最近修改时间
				}, {
					"dictionaryId": 224,
					"name": '六韬',
					"updatetime": 412876543210 //最近修改时间
				}, {
					"dictionaryId": 225,
					"name": '三略',
					"updatetime": 512876543210 //最近修改时间
				}
			]
		}
	});
	//result
	$httpBackend.whenPOST(URLs.APIOriginUrl + 'result/').respond({
		data: true
	});
});